package com.stx.bms.web;

import com.stx.bms.dao.BlogDAO;
import com.stx.bms.dao.BlogDAOImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/admin/blog-update")
public class BlogUpdateServlet extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String id = request.getParameter("id");
        String title = request.getParameter("title");
        String content = request.getParameter("content");

        BlogDAO dao = new BlogDAOImpl();
        dao.update( Integer.parseInt(id) , title, content);

        response.sendRedirect("blog-list");
    }
}
